package com.cat.greedyAlgorithm;

import java.util.Arrays;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/minimum-score-by-changing-two-elements/description/
 * @create 2025/8/22 15:58
 * @since JDK17
 */

public class Solution14 {
    public int minimizeSum(int[] nums) {
        int n = nums.length, ans = Integer.MAX_VALUE;
        Arrays.sort(nums);
        ans = Math.min(nums[n - 3] - nums[0], nums[n - 1] - nums[2]);
        ans = Math.min(nums[n - 2] - nums[1], ans);
        return ans;
    }
}
